package model;

public class GGA {

	private Temps time;
	private int quality;
	private int satellites;
	private float hDilution;
	private String altitude;
	private String hGeoid;
	private int lastUpdate;
	private int IDNumber;
	private String checksum;
	private Coordenada longitude;
	private Coordenada latitude;
	private double[] cartesiana;

	public GGA() {
		super();
	}

	public GGA(Temps time, int quality, int satellites, float hDilution,
			String altitude, String hGeoid, int lastUpdate, int iDNumber,
			String checksum, Coordenada longitude, Coordenada latitude) {
		super();
		this.time = time;
		this.quality = quality;
		this.satellites = satellites;
		this.hDilution = hDilution;
		this.altitude = altitude;
		this.hGeoid = hGeoid;
		this.lastUpdate = lastUpdate;
		IDNumber = iDNumber;
		this.checksum = checksum;
		this.longitude = longitude;
		this.latitude = latitude;
	}

	/**
	 * 
	 * @return time
	 */
	public Temps getTime() {
		return time;
	}

	/**
	 * 
	 * @param time
	 */
	public void setTime(String time) {
		Temps aux = new Temps();
		aux.setHores(Integer.parseInt(time.charAt(0) + "") * 10
				+ Integer.parseInt(time.charAt(1) + ""));
		aux.setMinuts(Integer.parseInt(time.charAt(2) + "") * 10
				+ Integer.parseInt(time.charAt(3) + ""));
		aux.setSegons(Integer.parseInt(time.charAt(4) + "") * 10
				+ Integer.parseInt(time.charAt(5) + ""));
		aux.setCentesimes(Integer.parseInt(time.charAt(7) + "")
				* 100
				+ (Integer.parseInt(time.charAt(8) + "") * 10 + Integer
						.parseInt(time.charAt(9) + "")));
		this.time = aux;
	}

	/**
	 * 
	 * @return quality
	 */
	public int getQuality() {
		return quality;
	}

	/**
	 * 
	 * @param quality
	 */
	public void setQuality(int quality) {
		this.quality = quality;
	}

	/**
	 * 
	 * @return satellites
	 */
	public int getSatellites() {
		return satellites;
	}

	/**
	 * 
	 * @param satellites
	 */
	public void setSatellites(int satellites) {
		this.satellites = satellites;
	}

	/**
	 * 
	 * @return hDilution
	 */
	public float gethDilution() {
		return hDilution;
	}

	/**
	 * 
	 * @param hDilution
	 */
	public void sethDilution(float hDilution) {
		this.hDilution = hDilution;
	}

	/**
	 * 
	 * @return altitude
	 */
	public String getAltitude() {
		return altitude;
	}

	/**
	 * 
	 * @param altitude
	 */
	public void setAltitude(String altitude) {
		this.altitude = altitude;
	}

	/**
	 * 
	 * @return hGeoid
	 */
	public String gethGeoid() {
		return hGeoid;
	}

	/**
	 * 
	 * @param hGeoid
	 */
	public void sethGeoid(String hGeoid) {
		this.hGeoid = hGeoid;
	}

	/**
	 * 
	 * @return lastUpdate
	 */
	public int getLastUpdate() {
		return lastUpdate;
	}

	/**
	 * 
	 * @param lastUpdate
	 */
	public void setLastUpdate(int lastUpdate) {
		this.lastUpdate = lastUpdate;
	}

	/**
	 * 
	 * @return IDNumber
	 */
	public int getIDNumber() {
		return IDNumber;
	}

	/**
	 * 
	 * @param iDNumber
	 */
	public void setIDNumber(int iDNumber) {
		IDNumber = iDNumber;
	}

	/**
	 * 
	 * @return checksum
	 */
	public String getChecksum() {
		return checksum;
	}

	/**
	 * 
	 * @param checksum
	 */
	public void setChecksum(String checksum) {
		this.checksum = checksum;
	}

	/**
	 * 
	 * @return longitude
	 */
	public Coordenada getLongitude() {
		return longitude;
	}

	/**
	 * 
	 * @param longitude
	 */
	public void setLongitude(Coordenada longitude) {
		this.longitude = longitude;
	}

	/**
	 * 
	 * @return latitude
	 */
	public Coordenada getLatitude() {
		return latitude;
	}

	/**
	 * 
	 * @param latitude
	 */
	public void setLatitude(Coordenada latitude) {
		this.latitude = latitude;
	}

	/**
	 * 
	 * @return cartesiana
	 */
	public double[] getCartesiana() {
		return cartesiana;
	}

	public void setCartesiana(double[] cartesiana) {
		this.cartesiana = cartesiana;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + IDNumber;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		GGA other = (GGA) obj;
		if (IDNumber != other.IDNumber)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "GGA [time=" + time + ", quality=" + quality + ", satellites="
				+ satellites + ", hDilution=" + hDilution + ", altitude="
				+ altitude + ", hGeoid=" + hGeoid + ", lastUpdate="
				+ lastUpdate + ", IDNumber=" + IDNumber + ", checksum="
				+ checksum + ", longitude=" + longitude + ", latitude="
				+ latitude + "]";
	}
}
